package main

import (
	"fmt"
	"sync"
)

func main() {
	var wg sync.WaitGroup
	wg.Add(5)
	go add1(1, &wg)
	go add1(2, &wg)
	go add1(3, &wg)
	go sub1(4, &wg)
	go sub1(5, &wg)
	wg.Wait()
	fmt.Println("main")

}

func add1(i int, wg *sync.WaitGroup) {
	defer wg.Done()
	fmt.Println("add", i)
}

func sub1(i int, wg *sync.WaitGroup) {
	defer wg.Done()
	fmt.Println("sub", i)
}
